function addZero(num) {
  return num < 10 ? "0" + num : num;
}
export default {
  addZero: function(num) {
    return num < 10 ? "0" + num : num;
  },
  formatDateTime: function(date) {
    const time = new Date(Date.parse(date));
    time.setTime(time.setHours(time.getHours()));
    const Y = time.getFullYear() + ".";
    const M = this.addZero(time.getMonth() + 1) + ".";
    const D = this.addZero(time.getDate()) + " ";
    const h = this.addZero(time.getHours()) + ":";
    const m = this.addZero(time.getMinutes()) + ":";
    const s = this.addZero(time.getSeconds());
    return Y + M + D + h + m + s;
  },
  formatDateTime2: function(date) {
    const time = new Date(Date.parse(date));
    time.setTime(time.setHours(time.getHours()));
    const Y = time.getFullYear();
    const M = time.getMonth() + 1;

    return Y + "年" + M + "月";
  },
  formatDateTime3: function(date) {
    const time = new Date(Date.parse(date));
    time.setTime(time.setHours(time.getHours()));
    const Y = time.getFullYear();
    const M = time.getMonth() + 1;
    const D = this.addZero(time.getDate()) + " ";
    return Y + "年" + M + "月" + D + "日";
  },
};
